﻿using Nemerle.Collections;
using Nemerle.Text;
using Nemerle.Utility;
using Nemerle.Compiler;

using System;
using System.Collections.Generic;
using System.Linq;

using PEG = Nemerle.Peg;

namespace Nemerle2.Parser
{
  public abstract class LocationConverter
  {
    public abstract Convert(loc : PEG.Location) : Location;

    public static Default : LocationConverter = DefaultLocationConverter();
  }

  public sealed class DefaultLocationConverter : LocationConverter
  {
    public override Convert(loc : PEG.Location) : Location
    {
      def (startLine, startCol) = loc.StartLineColumn;
      def (endLine, endCol) = loc.EndLineColumn;
      Location(loc.Source.FileIndex, startLine, startCol, endLine, endCol)
    }
  }
}
